package com.example.demo.vo;

import lombok.Data;

@Data
public class ResponseVO {
    // 响应前端状态码: 1 : 成功，0 : 系统异常,999 : 业务错误
    private Integer status;
    // 响应前端消息
    private String message;
    // 返回的数据对象
    private Object data;

    private int nowPage;
    private int totalPage;
    public static ResponseVO success(String msg){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(1);
        vo.setMessage(msg);
        return vo;
    }
    public static ResponseVO success(int nowPage,int totalPage,Object data){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(1);
        vo.setData(data);
        vo.setNowPage(nowPage);
        vo.setTotalPage(totalPage);
        return vo;
    }
    public static ResponseVO success(String msg,Object data){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(1);
        vo.setMessage(msg);
        vo.setData(data);
        return vo;
    }
    public static ResponseVO fail(String msg){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(999);
        vo.setMessage(msg);
        return vo;
    }
    public static ResponseVO fail(Object data){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(999);
        vo.setData(data);
        return vo;
    }
    public static ResponseVO fail(String msg,Object data){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(999);
        vo.setMessage(msg);
        vo.setData(data);
        return vo;
    }
    public static ResponseVO error(String msg){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(0);
        vo.setMessage(msg);
        return vo;
    }
    public static ResponseVO error(Object data){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(0);
        vo.setData(data);
        return vo;
    }
    public static ResponseVO error(String msg,Object data){
        ResponseVO vo = new ResponseVO();
        vo.setStatus(0);
        vo.setMessage(msg);
        vo.setData(data);
        return vo;
    }
}
